const Controller = require("../controllers/pet");

const documentation = require("../schema/pet");

const { upload } = require("./../index");

const { checkAuth } = require("../utils/checkAuth");
const { checkPermission } = require("../utils/checkPermission");

const routes = [
  {
    method: "GET",
    url: "/:id",
    preHandler: [checkAuth, checkPermission],
    handler: Controller.getPetDetail,
    config: {
      tag: "pet",
    },
    schema: documentation.getPetDetailSchema,
  },
  {
    method: "POST",
    url: "",
    preHandler: upload.array("photoUrls"),
    handler: Controller.addPet,
    config: {
      tag: "pet",
    },
    schema: documentation.addPetSchema,
  },
  {
    method: "PUT",
    url: "/:id",
    handler: Controller.putPet,
    config: {
      tag: "pet",
    },
    schema: documentation.putPetSchema,
  },
  {
    method: "DELETE",
    url: "/:id",
    handler: Controller.deletePet,
    config: {
      tag: "pet",
    },
    schema: documentation.deletePetSchema,
  },
  {
    method: "GET",
    url: "",
    handler: Controller.getPetStatus,
    config: {
      tag: "pet",
    },
    schema: documentation.getPetStatusSchema,
  },
];

module.exports = routes;
